package game;

import static org.junit.Assert.*;

import java.util.ArrayList;

import game.Card.Value;
import game.GameState.Phase;

import org.junit.Test;

public class GameTests {

	@Test
	public void test1() {
		GameState game1 = new GameState();
		game1.addPlayer("Joe");
		game1.dealCards();
		System.out.println(game1);
		GameState game2 = new GameState(game1.toString());
		assertTrue(game1.equals(game2));
	}
	@Test
	public void test2() {
		GameState game1 = new GameState();
		game1.addPlayer("Joe");
		game1.addPlayer("Mark");
		game1.dealCards();
		game1.takeTurn(0, TurnAction.CHECKORCALL, 0);
		game1.takeTurn(1, TurnAction.FOLD, 0);
		assertTrue(game1.getPhase() == Phase.WINNER);
	}
	@Test
	public void test3() {
		GameState game1 = new GameState();
		game1.addPlayer("Joe");
		game1.addPlayer("Mark");
		game1.dealCards();
		game1.takeTurn(0, TurnAction.CHECKORCALL, 0);
		game1.takeTurn(1, TurnAction.RAISE, 50);
		assertTrue(game1.getPhase() == Phase.BLINDS&&game1.currentTurn() == 0);
	}
	@Test
	public void test4() {
		GameState game1 = new GameState();
		game1.addPlayer("Joe");
		game1.addPlayer("Mark");
		game1.dealCards();
		game1.takeTurn(0, TurnAction.RAISE, 50);
		game1.takeTurn(1, TurnAction.CHECKORCALL, 0);
		assertTrue(game1.getPhase() == Phase.FLOP&&game1.currentTurn() == 0);
	}
	@Test
	public void test5(){
		ArrayList<Card> cards = new ArrayList<Card>();
		cards.add(new Card(Card.Suit.CLUBS,Value.ACE));
		cards.add(new Card(Card.Suit.CLUBS,Value.KING));
		cards.add(new Card(Card.Suit.CLUBS,Value.JACK));
		cards.add(new Card(Card.Suit.CLUBS,Value.QUEEN));
		cards.add(new Card(Card.Suit.CLUBS,Value.TEN));
		assertTrue(HandEvaluator.checkForRoyalFlush(cards) == Value.ACE);
	}
	@Test
	public void test6(){
		ArrayList<Card> cards = new ArrayList<Card>();
		cards.add(new Card(Card.Suit.CLUBS,Value.NINE));
		cards.add(new Card(Card.Suit.CLUBS,Value.KING));
		cards.add(new Card(Card.Suit.CLUBS,Value.JACK));
		cards.add(new Card(Card.Suit.CLUBS,Value.QUEEN));
		cards.add(new Card(Card.Suit.CLUBS,Value.TEN));
		assertTrue(HandEvaluator.checkForRoyalFlush(cards) == null);
		assertTrue(HandEvaluator.checkForStraightFlush(cards) == Value.KING);
	}
	@Test
	public void test7(){
		ArrayList<Card> cards = new ArrayList<Card>();
		cards.add(new Card(Card.Suit.CLUBS,Value.NINE));
		cards.add(new Card(Card.Suit.HEARTS,Value.NINE));
		cards.add(new Card(Card.Suit.SPADES,Value.NINE));
		cards.add(new Card(Card.Suit.DIAMONDS,Value.NINE));
		cards.add(new Card(Card.Suit.CLUBS,Value.TEN));
		assertTrue(HandEvaluator.checkForRoyalFlush(cards) == null);
		assertTrue(HandEvaluator.checkForStraightFlush(cards) == null);
		assertTrue(HandEvaluator.checkForFourOfAKind(cards) == Value.NINE);
	}
	@Test
	public void test8(){
		ArrayList<Card> cards = new ArrayList<Card>();
		cards.add(new Card(Card.Suit.CLUBS,Value.NINE));
		cards.add(new Card(Card.Suit.HEARTS,Value.NINE));
		cards.add(new Card(Card.Suit.SPADES,Value.NINE));
		cards.add(new Card(Card.Suit.SPADES,Value.TEN));
		cards.add(new Card(Card.Suit.CLUBS,Value.TEN));
		cards.add(new Card(Card.Suit.DIAMONDS,Value.TEN));
		assertTrue(HandEvaluator.checkForRoyalFlush(cards) == null);
		assertTrue(HandEvaluator.checkForStraightFlush(cards) == null);
		assertTrue(HandEvaluator.checkForFourOfAKind(cards) == null);
		assertTrue(HandEvaluator.checkForFullHouse(cards) == Value.TEN);
	}
	@Test
	public void test9(){
		ArrayList<Card> cards = new ArrayList<Card>();
		cards.add(new Card(Card.Suit.CLUBS,Value.KING));
		cards.add(new Card(Card.Suit.CLUBS,Value.QUEEN));
		cards.add(new Card(Card.Suit.CLUBS,Value.SIX));
		cards.add(new Card(Card.Suit.CLUBS,Value.NINE));
		cards.add(new Card(Card.Suit.CLUBS,Value.TEN));
		assertTrue(HandEvaluator.checkForRoyalFlush(cards) == null);
		assertTrue(HandEvaluator.checkForStraightFlush(cards) == null);
		assertTrue(HandEvaluator.checkForFourOfAKind(cards) == null);
		assertTrue(HandEvaluator.checkForFullHouse(cards) == null);
		assertTrue(HandEvaluator.checkForFlush(cards) == Value.KING);
	}
	@Test
	public void test10(){
		ArrayList<Card> cards = new ArrayList<Card>();
		cards.add(new Card(Card.Suit.CLUBS,Value.SIX));
		cards.add(new Card(Card.Suit.SPADES,Value.SEVEN));
		cards.add(new Card(Card.Suit.CLUBS,Value.EIGHT));
		cards.add(new Card(Card.Suit.CLUBS,Value.NINE));
		cards.add(new Card(Card.Suit.CLUBS,Value.TEN));
		assertTrue(HandEvaluator.checkForRoyalFlush(cards) == null);
		assertTrue(HandEvaluator.checkForStraightFlush(cards) == null);
		assertTrue(HandEvaluator.checkForFourOfAKind(cards) == null);
		assertTrue(HandEvaluator.checkForFullHouse(cards) == null);
		assertTrue(HandEvaluator.checkForFlush(cards) == null);
		assertTrue(HandEvaluator.checkForStraight(cards) == Value.TEN);
	}
	@Test
	public void test11(){
		ArrayList<Card> cards = new ArrayList<Card>();
		cards.add(new Card(Card.Suit.CLUBS,Value.SIX));
		cards.add(new Card(Card.Suit.SPADES,Value.NINE));
		cards.add(new Card(Card.Suit.DIAMONDS,Value.NINE));
		cards.add(new Card(Card.Suit.CLUBS,Value.NINE));
		cards.add(new Card(Card.Suit.CLUBS,Value.TEN));
		assertTrue(HandEvaluator.checkForRoyalFlush(cards) == null);
		assertTrue(HandEvaluator.checkForStraightFlush(cards) == null);
		assertTrue(HandEvaluator.checkForFourOfAKind(cards) == null);
		assertTrue(HandEvaluator.checkForFullHouse(cards) == null);
		assertTrue(HandEvaluator.checkForFlush(cards) == null);
		assertTrue(HandEvaluator.checkForStraight(cards) == null);
		assertTrue(HandEvaluator.checkForThreeOfAKind(cards) == Value.NINE);
	}
	@Test
	public void test12(){
		ArrayList<Card> cards = new ArrayList<Card>();
		cards.add(new Card(Card.Suit.CLUBS,Value.NINE));
		cards.add(new Card(Card.Suit.SPADES,Value.JACK));
		cards.add(new Card(Card.Suit.DIAMONDS,Value.JACK));
		cards.add(new Card(Card.Suit.SPADES,Value.NINE));
		cards.add(new Card(Card.Suit.CLUBS,Value.TEN));
		assertTrue(HandEvaluator.checkForRoyalFlush(cards) == null);
		assertTrue(HandEvaluator.checkForStraightFlush(cards) == null);
		assertTrue(HandEvaluator.checkForFourOfAKind(cards) == null);
		assertTrue(HandEvaluator.checkForFullHouse(cards) == null);
		assertTrue(HandEvaluator.checkForFlush(cards) == null);
		assertTrue(HandEvaluator.checkForStraight(cards) == null);
		assertTrue(HandEvaluator.checkForThreeOfAKind(cards) == null);
		assertTrue(HandEvaluator.checkForTwoPair(cards) == Value.JACK);
	}
	@Test
	public void test13(){
		ArrayList<Card> cards = new ArrayList<Card>();
		cards.add(new Card(Card.Suit.CLUBS,Value.NINE));
		cards.add(new Card(Card.Suit.SPADES,Value.JACK));
		cards.add(new Card(Card.Suit.DIAMONDS,Value.QUEEN));
		cards.add(new Card(Card.Suit.SPADES,Value.NINE));
		cards.add(new Card(Card.Suit.CLUBS,Value.TEN));
		assertTrue(HandEvaluator.checkForRoyalFlush(cards) == null);
		assertTrue(HandEvaluator.checkForStraightFlush(cards) == null);
		assertTrue(HandEvaluator.checkForFourOfAKind(cards) == null);
		assertTrue(HandEvaluator.checkForFullHouse(cards) == null);
		assertTrue(HandEvaluator.checkForFlush(cards) == null);
		assertTrue(HandEvaluator.checkForStraight(cards) == null);
		assertTrue(HandEvaluator.checkForThreeOfAKind(cards) == null);
		assertTrue(HandEvaluator.checkForTwoPair(cards) == null);
		assertTrue(HandEvaluator.checkForPair(cards) == Value.NINE);
	}
	@Test
	public void test14(){
		ArrayList<Card> cards = new ArrayList<Card>();
		cards.add(new Card(Card.Suit.CLUBS,Value.NINE));
		cards.add(new Card(Card.Suit.SPADES,Value.SEVEN));
		cards.add(new Card(Card.Suit.DIAMONDS,Value.TWO));
		cards.add(new Card(Card.Suit.SPADES,Value.THREE));
		cards.add(new Card(Card.Suit.CLUBS,Value.EIGHT));
		assertTrue(HandEvaluator.checkForRoyalFlush(cards) == null);
		assertTrue(HandEvaluator.checkForStraightFlush(cards) == null);
		assertTrue(HandEvaluator.checkForFourOfAKind(cards) == null);
		assertTrue(HandEvaluator.checkForFullHouse(cards) == null);
		assertTrue(HandEvaluator.checkForFlush(cards) == null);
		assertTrue(HandEvaluator.checkForStraight(cards) == null);
		assertTrue(HandEvaluator.checkForThreeOfAKind(cards) == null);
		assertTrue(HandEvaluator.checkForTwoPair(cards) == null);
		assertTrue(HandEvaluator.checkForPair(cards) == null);
		assertTrue(HandEvaluator.highestCard(cards) == Value.NINE);
	}

}
